package gof_003_行为型_Behavioral.gof_005_责任链_ChainOfResponsibility.gof_003_Normal;


import gof_003_行为型_Behavioral.gof_005_责任链_ChainOfResponsibility.gof_004_Chain.Utils;

import java.util.concurrent.TimeUnit;

public class Main {
    public static void main(String[] args) {

        System.out.println("用户选购...");
        sleep(1);


        int scannerPay = Utils.scanner("请模拟用户是否付款！[1]未付款\t[2]付款");
        if(scannerPay==1){
            System.out.println("用户未付款!订单结束!");
            return;
        }else if (scannerPay==2){
            System.out.println("用户付款了!");
        }

        System.out.println("商家接单...");
        sleep(1);

        System.out.println("骑手接单...");
        sleep(1);

        System.out.println("骑手正在途中...");
        sleep(1);



        int scanner = Utils.scanner("请模拟骑手是否准确送达！[1]翻车\t[2]送达");
        if(scanner==1){
            System.out.println("骑手送达!!!");
            System.out.println("订单完成!!!");
        }else if (scanner == 2){
            System.out.println("骑手翻车了!!!");
            System.out.println("订单退款!!!");
        }
    }

    /**
     * 睡眠 n 秒
     * @param seconds
     */
    public static void sleep(int seconds) {
        try {
            TimeUnit.SECONDS.sleep(seconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}